﻿@model EnableAuthenticatorModel
@{
    ViewData["Title"] = "Enable authenticator";
}

<h4>@ViewData["Title"]</h4>
<partial name="_StatusMessage" model="@TempData["StatusMessage"]" />

<p>To use an authenticator app go through the following steps:</p>
<ol class="list mb-0" style="margin-right: 40px">
    <li>
        <p>
            Download a two-factor authenticator app like Microsoft Authenticator for
            <a href="https://go.microsoft.com/fwlink/?Linkid=825072">Android</a> and
            <a href="https://go.microsoft.com/fwlink/?Linkid=825073">iOS</a> or
            Google Authenticator for
            <a href="https://play.google.com/store/apps/details?id=com.google.android.apps.authenticator2&amp;hl=en">Android</a> and
            <a href="https://itunes.apple.com/us/app/google-authenticator/id388497605?mt=8">iOS</a>.
        </p>
    </li>
    <li>
        <p>Scan the QR Code or enter this key <kbd>@Model.SharedKey</kbd> into your two factor authenticator app. Spaces and casing do not matter.</p>
        <div id="qrCode" class="mb-4 d-flex justify-content-center"></div>
        <div id="qrCodeData" data-url="@Model.AuthenticatorUri"></div>
    </li>
    <li>
        Once you have scanned the QR code or input the key above, your two factor authentication app will provide you
        with a unique code. Enter the code in the confirmation box below.
        <div class="card mt-3 mb-4"><div class="card-body">
        <form method="post">
            <div class="form-group mb-2">
                <label asp-for="Code" class="control-label">Verification Code</label>
                <input asp-for="Code" class="form-control" autocomplete="off" />
                <span asp-validation-for="Code" class="text-danger"></span>
            </div>
            <button type="submit" class="btn btn-primary btn-sm">Verify</button>
            <div asp-validation-summary="ModelOnly" class="text-danger"></div>
        </form>
        </div></div>
    </li>
    <li>
        After you enable this authenticator, the old recovery codes will expire and you will get new recovery codes.
        Remember to save them.
    </li>
</ol>


@section Scripts {
    <partial name="_ValidationScriptsPartial" />
    <script type="text/javascript" src="~/lib/qrcodejs/qrcode.min.js"></script>
    <script type="text/javascript">
        new QRCode(document.getElementById("qrCode"),
            {
                text: "@Html.Raw(Model.AuthenticatorUri)",
                width: 200,
                height: 200,
                correctLevel: QRCode.CorrectLevel.M
            });
    </script>
}
